resource "google_bigquery_dataset" "test" {
  dataset_id = "<%= ctx[:vars]['dataset_id'] %>"
}

resource "google_bigquery_table" "test" {
  deletion_protection = false
  table_id   = "<%= ctx[:vars]['table_id'] %>"
  dataset_id = google_bigquery_dataset.test.dataset_id
  time_partitioning {
    type = "DAY"
  }
  schema = <<EOH
[
  {
    "name": "city",
    "type": "RECORD",
    "fields": [
  {
    "name": "id",
    "type": "INTEGER"
  },
  {
    "name": "coord",
    "type": "RECORD",
    "fields": [
    {
      "name": "lon",
      "type": "FLOAT"
    },
    {
      "name": "lat",
      "type": "FLOAT"
    }
    ]
  }
    ]
  },
  {
    "name": "country",
    "type": "RECORD",
    "fields": [
  {
    "name": "id",
    "type": "INTEGER"
  },
  {
    "name": "name",
    "type": "STRING"
  }
    ]
  }
]
EOH
}
